package com.ruoyi.shop.goods.service.impl;

import java.util.List;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.shop.goods.domain.ShopGoodsEvaluate;
import com.ruoyi.shop.goods.mapper.ShopGoodsEvaluateMapper;
import com.ruoyi.shop.goods.service.IShopGoodsEvaluateService;
import com.ruoyi.shop.goods.vo.ShopGoodsEvaluateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品评价Service业务层处理
 * 
 * @author xuxiang
 * @date 2023-09-19
 */
@Service
public class ShopGoodsEvaluateServiceImpl implements IShopGoodsEvaluateService {

	@Autowired
	private ShopGoodsEvaluateMapper shopGoodsEvaluateMapper;

	/**
	 * 查询商品评论
	 * 
	 * @param EvaluateId 商品评论主键
	 * @return 商品评论
	 */
	@Override
	public ShopGoodsEvaluateVo selectEvaluateById(Long EvaluateId) {
		return shopGoodsEvaluateMapper.selectEvaluateById(EvaluateId);
	}

	/**
	 * 根据商品Id查询评论列表
	 * 
	 * @param goodsId
	 * @return
	 */
	public List<ShopGoodsEvaluateVo> selectEvaluateByGoodsId(Long goodsId) {
		ShopGoodsEvaluateVo vo=new ShopGoodsEvaluateVo();
		vo.setGoodsId(goodsId);
		return shopGoodsEvaluateMapper.selectEvaluateList(vo);
	
	
	}

	/**
	 * 查询商品评论列表
	 * 
	 * @param shopGoodsEvaluate 商品评论
	 * @return 商品评论
	 */
	@Override
	public List<ShopGoodsEvaluateVo> selectEvaluateList(ShopGoodsEvaluateVo vo) {
		return shopGoodsEvaluateMapper.selectEvaluateList(vo);
	}

	/**
	 * 新增商品评论
	 * 
	 * @param shopGoodsEvaluate 商品评论
	 * @return 结果
	 */
	@Override
	public int insertGoodsEvaluate(ShopGoodsEvaluate shopGoodsEvaluate) {
		shopGoodsEvaluate.setCreateTime(DateUtils.getNowDate());
		return shopGoodsEvaluateMapper.insertGoodsEvaluate(shopGoodsEvaluate);
	}

	/**
	 * 修改商品评论
	 * 
	 * @param shopGoodsEvaluate 商品评论
	 * @return 结果
	 */
	@Override
	public int updateGoodsEvaluate(ShopGoodsEvaluate shopGoodsEvaluate) {
		shopGoodsEvaluate.setUpdateTime(DateUtils.getNowDate());
		return shopGoodsEvaluateMapper.updateGoodsEvaluate(shopGoodsEvaluate);
	}

	/**
	 * 批量删除商品评论
	 * 
	 * @param EvaluateIds 需要删除的商品评论主键
	 * @return 结果
	 */
	@Override
	public int deleteEvaluateByIds(String EvaluateIds) {
		return shopGoodsEvaluateMapper.deleteEvaluateByIds(Convert.toStrArray(EvaluateIds));
	}

	/**
	 * 删除商品评论信息
	 * 
	 * @param EvaluateId 商品评论主键
	 * @return 结果
	 */
	@Override
	public int deleteEvaluateById(Long EvaluateId) {
		return shopGoodsEvaluateMapper.deleteEvaluateById(EvaluateId);
	}

	/**
	 * 改变评论显示状态
	 * 
	 * @param ShopGoodsEvaluate 评论信息
	 * @return 结果
	 */
	@Override
	public int changeStatus(ShopGoodsEvaluate ShopGoodsEvaluate) {
		return shopGoodsEvaluateMapper.updateGoodsEvaluate(ShopGoodsEvaluate);
	}

}
